import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @author zyj
 * @date 2022年06月09日 16:27
 */
public class 打印顺序是ABCABC1 {
    public static void main(String[] args) {
        Object obj = new Object();
        Thread a = new MyThreadA(obj,"A");
        Thread b = new MyThreadA(obj,"B");
        Thread c = new MyThreadA(obj,"C");
        a.setPriority(10);
        b.setPriority(5);
        c.setPriority(1);
        a.start();
        b.start();
        c.start();
    }
}

class MyThreadA extends Thread{
    private Object obj;
    public MyThreadA(Object obj,String name){
        super(name);
        this.obj = obj;
    }
    @Override
    public void run() {
          synchronized (obj) {
              for (int i = 0; i < 5; i++) {
                  System.out.println(Thread.currentThread().getName());

                  obj.notify();
                  try {
                      obj.wait();
                  } catch (InterruptedException e) {
                      e.printStackTrace();
                  }
              }
              obj.notifyAll();
          }


    }
}